﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PatientScheduler.aspx.cs"
    Inherits="PatientScheduler" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>دریافت نوبت</title>
    <style type="text/css">
        .Disabled
        {
            background-color: Grey !important;
        }
        .Enabled
        {
            background-color: Red !important;
        }
        .RadScheduler .rsAptSubject
        {
            text-align: right;
            padding: 4px 0 1px;
            margin: 0 0 3px;
            font-size: 12px;
            font-weight: bold;
            color: #369;
            height: 17px;
            border-bottom: 1px solid #99DEFD;
            width: 100%;
        }
        
        .RadScheduler .rsAdvancedEdit .RadColorPicker label
        {
            text-align: right;
            display: block;
            padding: 0;
        }
    </style>
    <script type="text/javascript">
        function OnClientAppointmentEditing(sender, eventArgs) {       
                eventArgs.set_cancel(true);
        }
</script>

</head>
<body>
    <form id="form1" runat="server">
    <div style="text-align: center">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="DoctorScheduler">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="DoctorScheduler" LoadingPanelID="RadAjaxLoadingPanel1">
                        </telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1"
            CssClass="exampleContainer">
            <telerik:RadComboBox runat="Server" ID="GroupingDirectionComboBox" Skin="Vista" OnSelectedIndexChanged="GroupingDirectionComboBox_SelectedIndexChanged"
                AutoPostBack="True">
                <Items>
                    <telerik:RadComboBoxItem Text="افقی" Value="Horizontal"></telerik:RadComboBoxItem>
                    <telerik:RadComboBoxItem Text="عمودی" Value="Vertical"></telerik:RadComboBoxItem>
                </Items>
            </telerik:RadComboBox>
            :نمایش به صورت
            <telerik:RadScheduler runat="server" ID="PatientsScheduler" Width="100%" Height="100%"
                GroupBy="Doctor" AppointmentStyleMode="Default" DataSourceID="PatientsAppointmentEntityDataSource"
                DataKeyField="Id" DataSubjectField="FirstName" DataStartField="Start" DataEndField="End"
                OnResourceHeaderCreated="PatientsScheduler_ResourceHeaderCreated" OnAppointmentCreated="PatientsScheduler_AppointmentCreated"
                OnAppointmentDataBound="PatientsScheduler_AppointmentDataBound" OnDataBound="PatientsScheduler_DataBound"
                OnFormCreating="PatientsScheduler_FormCreating" EditFormDateFormat="yyyy/MM/dd"
                EditFormTimeFormat="h:mm" FirstDayOfWeek="Saturday" HoursPanelTimeFormat="H:mm"
                LastDayOfWeek="Thursday" StartInsertingInAdvancedForm="True" TimeZoneID="Iran Standard Time"
                TimeZoneOffset="03:30:00" WorkDayEndTime="18:00:00" OnTimeSlotCreated="PatientsScheduler_TimeSlotCreated"
                OnFormCreated="PatientsScheduler_FormCreated"
                OnClientAppointmentEditing="OnClientAppointmentEditing">
                <ResourceHeaderTemplate>
                    <asp:Panel ID="ResourceImageWrapper" runat="server" CssClass="ResCustomClass">
                        <asp:Image ID="DoctorImage" runat="server"></asp:Image>
                    </asp:Panel>
                </ResourceHeaderTemplate>
                <Reminders Enabled="true" />
                <AppointmentTemplate>
                    <div class="rsAptSubject">
                        <%# Eval("Id") %>
                    </div>
                </AppointmentTemplate>
                <AdvancedInsertTemplate>
                    <div id="qsfexAdvEditWrapper" dir="rtl">
                        <div id="qsfexAdvEditInnerWrapper" class="technical">
                            <div class="qsfexAdvAppType">
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label4" AssociatedControlID="FirstNameTextBox" runat="server" CssClass="inline-label">نام بیمار: </asp:Label>
                                <asp:TextBox ID="FirstNameTextBox" Rows="2" Columns="20" runat="server" 
                                    Width="97%" TextMode="MultiLine"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="FirstNameRequiredFieldValidator" runat="server" ValidationGroup="Insert"
                                    ControlToValidate="FirstNameTextBox" ErrorMessage="نام بیمار اجباری">*</asp:RequiredFieldValidator>
                                <br />
                            </div>
                               <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label7" AssociatedControlID="LastNameTextBox" runat="server" CssClass="inline-label">نام خانوادگی بیمار: </asp:Label>
                                <asp:TextBox ID="LastNameTextBox" Rows="2" Columns="20" runat="server" 
                                    Width="97%" TextMode="MultiLine"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="LastNameRequiredFieldValidator" runat="server" ValidationGroup="Insert"
                                    ControlToValidate="LastNameTextBox" ErrorMessage="نام خانوادگی بیمار اجباری">*</asp:RequiredFieldValidator>
                                <br />
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label5" AssociatedControlID="StartInput" runat="server" CssClass="inline-label">زمان شروع:</asp:Label>
                                <telerik:RadDateInput ID="StartInput" SelectedDate='<%# Bind("Start") %>' runat="server"
                                    EnableSingleInputRendering="false">
                                </telerik:RadDateInput>
                                <br />
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label6" AssociatedControlID="EndInput" runat="server" CssClass="inline-label">زمان پایان:</asp:Label>
                                <telerik:RadDateInput ID="EndInput" SelectedDate='<%# Bind("End") %>' runat="server"
                                    EnableSingleInputRendering="false">
                                </telerik:RadDateInput><br />
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label3" AssociatedControlID="AppointmentTypeComboBox" runat="server"
                                    CssClass="inline-label">نوع ملاقات:</asp:Label>
                                <telerik:RadComboBox runat="server" ID="AppointmentTypeComboBox" DataTextField="Name"
                                    DataValueField="Id" Width="90%" Skin="Office2007" 
                                    DataSourceID="AppointmentTypesEntityDataSource">
                                </telerik:RadComboBox>
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label1" AssociatedControlID="DoctorsComboBox" runat="server" CssClass="inline-label">نام پزشک:</asp:Label>
                                <telerik:RadComboBox runat="server" ID="DoctorsComboBox" DataTextField="Name" DataValueField="Id"
                                    Width="90%" Skin="Office2007" DataSourceID="DoctorsEntityDataSource">
                                </telerik:RadComboBox>
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:Label ID="Label2" AssociatedControlID="RoomsComboBox" runat="server" CssClass="inline-label">محل حضور:</asp:Label>
                                <telerik:RadComboBox runat="server" ID="RoomsComboBox" DataTextField="Name" DataValueField="Id"
                                    Width="90%" Skin="Office2007" DataSourceID="RoomsEntityDataSource">
                                </telerik:RadComboBox>
                            </div>
                            <div class="qsfexAdvEditControlWrapper">
                                <asp:LinkButton ID="InsertButton" runat="server" OnClick="InsertButton_Click">
                                    <asp:Image runat="server" ID="Image4" ValidationGroup="Insert" ImageUrl="App_Themes/Default/Images/ok.png"
                                        AlternateText="insert"></asp:Image></asp:LinkButton>
                                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                    Style="margin-right: 8px;">
                                    <asp:Image runat="server" ID="Image5" ImageUrl="App_Themes/Default/Images/cancel.png"
                                        AlternateText="cancel"></asp:Image></asp:LinkButton>
                            </div>
                        </div>
                    </div>
                </AdvancedInsertTemplate>   
                <AdvancedForm DateFormat="yyyy/MM/dd" TimeFormat="h:mm" Width="100%" />
                <ResourceTypes>
                    <telerik:ResourceType KeyField="Id" Name="Doctor" TextField="Name" ForeignKeyField="DoctorAppointment.DoctorId"
                        DataSourceID="DoctorsEntityDataSource"></telerik:ResourceType>
                    <telerik:ResourceType KeyField="Id" Name="Room" TextField="Name" ForeignKeyField="DoctorAppointment.RoomId"
                        DataSourceID="RoomsEntityDataSource"></telerik:ResourceType>
                    <telerik:ResourceType KeyField="Id" Name="AppointmentType" TextField="Name" ForeignKeyField="DoctorAppointment.AppointmentTypeId"
                        DataSourceID="AppointmentTypesEntityDataSource"></telerik:ResourceType>                  
                </ResourceTypes>
                <ResourceStyles>
                    <telerik:ResourceStyleMapping Type="Doctor" Key="1" BackColor="#eb901b"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Doctor" Key="2" BackColor="#8fd21b"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Doctor" Key="3" BackColor="#278ce9"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Doctor" Key="4" BackColor="#f14db2"></telerik:ResourceStyleMapping>
                </ResourceStyles>
                <TimelineView UserSelectable="false" />
                <TimeSlotContextMenuSettings EnableDefault="true" />
                <AppointmentContextMenuSettings EnableDefault="true" />
            </telerik:RadScheduler>
        </telerik:RadAjaxPanel>
        <asp:EntityDataSource ID="DoctorsAppointmentEntityDataSource" runat="server" ConnectionString="name=DatabaseEntities"
            DefaultContainerName="DatabaseEntities" EntitySetName="DoctorAppointments" EnableInsert="True">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="PatientsAppointmentEntityDataSource" runat="server" ConnectionString="name=DatabaseEntities"
            DefaultContainerName="DatabaseEntities" EnableInsert="True" EntitySetName="PatientAppointments" Include="DoctorAppointment">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="RoomsEntityDataSource" runat="server" ConnectionString="name=DatabaseEntities"
            DefaultContainerName="DatabaseEntities" EntitySetName="Rooms">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="DoctorsEntityDataSource" runat="server" ConnectionString="name=DatabaseEntities"
            DefaultContainerName="DatabaseEntities" CommandText="SELECT it.[Id] , it.[FirstName] + ' ' + it.[LastName] as Name From DatabaseEntities.Doctors as it">
        </asp:EntityDataSource>
        <asp:EntityDataSource ID="AppointmentTypesEntityDataSource" runat="server" ConnectionString="name=DatabaseEntities"
            DefaultContainerName="DatabaseEntities" EntitySetName="AppointmentTypes">
        </asp:EntityDataSource>        
    </div>
    </form>
</body>
</html>
